﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyThietBi.DAL.Models;

namespace QuanLyThietBi.DAL
{
    public class TinhTrangDAO
    {
        public List<TINHTRANG> GetAllTinhTrang()
        {
            List<TINHTRANG> dsTinhTrang = null;
            try
            {
                using (var en = new QuanLyThietBiEntities())
                {
                    var ds = from tb in en.TINHTRANGs
                             select tb;
                    if (ds != null)
                    {
                        dsTinhTrang = ds.ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dsTinhTrang;
        }

        public string GetTinhTrangById(int tinhtrangId)
        {
            string tinhtrang = string.Empty;
            try
            {
                using (var en = new QuanLyThietBiEntities())
                {
                    var ds = from tt in en.TINHTRANGs
                             where tt.id == tinhtrangId
                             select tt;
                    if (ds != null)
                    {
                        tinhtrang = ds.FirstOrDefault().tinh_trang;
                        //dsLoaiTB = ds.ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return tinhtrang;
        }
    }
}
